{% load static %}
{% load my_tags1 %}
{% get_catageorys as catagorys %}
<ul class="nav justify-content-center">
  <li class="nav-item">
    <a class="nav-link active" aria-current="page" href="{% url 'main:index' %}">首页</a>
  </li>

  {% if request.user.is_authenticated %}
    <li class="nav-item">
      <a class="nav-link btn btn-sm btn-primary text-white px-3" href="{% url 'main:create' %}" role="button">发布文章</a>
    </li>

    <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
        个人中心
      </a>
      <ul class="dropdown-menu">
        <li><h6 class="dropdown-header">当前用户：{{ request.user }}</h6></li>
        <li><a class="dropdown-item" href="{% url 'user:manage' %}">文章管理</a></li>
        <li><a class="dropdown-item" href="{% url 'user:changepwd' %}">更改密码</a></li>
        <li><hr class="dropdown-divider"></li>
        <li><a class="dropdown-item" href="{% url 'user:logout' %}">退出</a></li>
      </ul>
    </li>
    {% for catagory in catagorys %}
      {% if catagory.children|length == 0 %}
        <li class="nav-item"><a class="nav-link" href="#">{{ catagory.title }}</a></li>
      {% else %}
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            {{catagory.title}}
          </a>
          <ul class="dropdown-menu">
            {% for catagory in catagory.children %}
              <li><a class="dropdown-item" href="#">{{ catagory.title }}</a></li>
            {% endfor %}
          </ul>
        </li>
      {% endif %}
    {% endfor %}

  {% else %}
    <li class="nav-item">
      <a class="nav-link" href="{% url 'user:rigest' %}">注册</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="{% url 'user:login' %}">登录</a>
    </li>
  {% endif %}

</ul>

<script src="/static/bootstrap/js/bootstrap.min.js"></script>
